/*
 * EEPROM.h
 *
 *  Created on: Jan 16, 2014
 *      Author: ppks
 */

#ifndef EEPROM_H_
#define EEPROM_H_


/********************************************************************************/
/* Constant Definition                                                          */
/********************************************************************************/
//temporary
// TODO: add it to the plog function
#define PLOG_SIZE                           0

#define EEPROM_SIZE                         0x1000

/* Data stored at the beginning of the EEPROM area */
#define EEPROM_GET_GLOBAL_INFO_OFFSET()     (0)
#define EEPROM_GET_CAL_DATA_OFFSET()        (EEPROM_GET_GLOBAL_INFO_OFFSET() + sizeof(ConfigInfo))
#define EEPROM_GET_CONFIG_SET_OFFSET(x)     (EEPROM_GET_CAL_DATA_OFFSET() + sizeof(calData) +  x * sizeof(FC_Config))
#define EEPROM_GET_GPS_CONFIG_OFFSET        (EEPROM_GET_CONFIG_SET_OFFSET(FC_CONFIG_MAX_SET_NUMBER + 1))
#define EEPROM_GET_WP_DATA_OFFSET           (EEPROM_GET_GPS_CONFIG_OFFSET + sizeof(GPS_Config))
#define EEPROM_GET_WP_RECORD_OFFSET(x)      (EEPROM_GET_WP_DATA_OFFSET + x * sizeof(WaypointRecord))

/* Data stored at the end of the EEPROM area */
#define EEPROM_GET_PLOG_OFFSET              (EEPROM_SIZE - PLOG_SIZE)
#define EEPROM_LAST_AVAILABLE_BYTE          (EEPROM_GET_PLOG_OFFSET - 4)

/********************************************************************************/
/* Exported Functions Prototypes                                                */
/********************************************************************************/
void EEPROM_ReadConfigInfo(void);
void EEPROM_WriteConfigInfo(void);
void EEPROM_UpdateConfigInfo(void);
bool EEPROM_ReadCalibrationData(void);
void EEPROM_WriteCalibrationData(void);
void EEPROM_UpdateCalibrationData(void);
bool EEPROM_ReadParams(uint8_t configSet);
void EEPROM_WriteParams(uint8_t configSet, uint8_t b);
void EEPROM_UpdateParams(uint8_t configSet, uint8_t b);
bool EEPROM_ReadGPSConfig(void);
void EEPROM_WriteGPSConfig(void);
void EEPROM_UpdateGPSConfig(void);
uint8_t EEPROM_GetMaxWaypointRecords(void);
bool EEPROM_ReadWPRecord(uint8_t recordIndex);
void EEPROM_WriteWPRecord(void);

/********************************************************************************/
/* Exported Variables Declaration                                               */
/********************************************************************************/


#endif /* EEPROM_H_ */
